/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package IsdComponent;

/**
 *
 * @author Shameera
 */
import java.io.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;

public class GetNodeValue {
    public static void main(String[] args) throws Exception {
        File file = new File("E:\\Employ.xml");
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.parse(file);
        new GetNodeValue().GettingText(doc);
    }
    public void GettingText(Document doc) {
       Element e = doc.getDocumentElement();
        NodeList nodeList = doc.getElementsByTagName("Employee");
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                Element element = (Element) node;
                NodeList nodelist = element.getElementsByTagName("Emp_Id");
                Element element1 = (Element) nodelist.item(0);
                NodeList fstNm = element1.getChildNodes();
                System.out.print("Emp_Id : " + (fstNm.item(0)).getNodeValue());
                System.out.println(fstNm.item(0).getAttributes().getLength());
               }
        }
    }
}